package com.itzg.svn;

import org.kohsuke.args4j.CmdLineException;
import org.kohsuke.args4j.CmdLineParser;

public class SvnBenchmarkMain {
	
	public SvnBenchmarkMain() {
	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// We'll make possibly two passes through the cmd line args
		// At first they may tell us to load from an XML config file. If so,
		// one more pass is needed to overlay the cmd line overrides
		SvnSlammerOptions options = new SvnSlammerOptions();
		CmdLineParser cParser = new CmdLineParser(options);
		try {
			cParser.parseArgument(args);
			if (options.isHelpRequested()) {
				cParser.printUsage(System.out);
				return;
			}
			if (options.getLoadFrom() != null) {
				options = SvnSlammerOptions.loadFrom(options.getLoadFrom());
				new CmdLineParser(options).parseArgument(args);
			}
		} catch (CmdLineException e) {
			System.err.println(e.getMessage());
			cParser.printUsage(System.err);
			return;
		}
		
		if (options.getSaveTo() != null) {
			options.save();
		}

		SvnSlammer benchmark = 
				new SvnSlammerLocal(options);
		benchmark.run();
	}
}
